/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable import/no-mutable-exports */
let CURRENT: Array<string>;
let CURRENT_TOKEN:string;
type CurrentAuthorityType = {access_token:string,permissions:Array<string>};
/**
 * use  authority or getAuthority
 * @param {string|()=>String} currentAuthority
 */
const renderAuthorize = <T>(Authorized: T): ((currentAuthority: CurrentAuthorityType) => T) => (
  currentAuthority: CurrentAuthorityType,
): T => {
  if (currentAuthority) {
    CURRENT = currentAuthority.permissions;
    CURRENT_TOKEN = currentAuthority.access_token;
  } else {
    CURRENT = [];
  }
  return Authorized;
};
export { CURRENT ,CURRENT_TOKEN};
export default <T>(Authorized: T) => renderAuthorize<T>(Authorized);
